-- CALC_HIDE_ITEM_MATERIAL_BONUS

-- 计算材料奖励（隐藏物件）
-- @param user      玩家对象
return function(user, bonusArg)
    local rand = DungeonM.getRandSeed("HIDE_ITEM") % 100;
    local rand1 = DungeonM.getRandSeed("HIDE_ITEM") % 100;
    local classId;
    local arr1 = {};
    local class = bonusArg.class;

    -- 蘑菇村庄
    if class == 759 then
        local bonusTimes = CaveHideItemM.getCaveBuildingBonusTimes(759);
        if rand > 50 then
            arr = ItemM.getFoodMaterial(1);
            return { 1, FormulaM.invoke("FETCH_BY_RAND", arr, rand1), 30, };
        elseif bonusTimes < 3 and rand > 30 then
            -- 奖励时需要记录次数
            return { 2, "gem", 3, };
        else
            arr = ItemM.getFoodMaterial(2);
            return { 1, FormulaM.invoke("FETCH_BY_RAND", arr, rand1), 15, };
        end
    end

    -- 废弃的锅炉
    if class == 765 then
        if rand > 40 then
            arr = ItemM.getFoodMaterial(1);
            return { 1, FormulaM.invoke("FETCH_BY_RAND", arr, rand1), 30, };
        else
            arr = ItemM.getFoodMaterial(2);
            return { 1, FormulaM.invoke("FETCH_BY_RAND", arr, rand1), 15, };
        end
    end

    -- 废弃的货车
    if class == 767 then
        if rand > 40 then
            arr1 = { 1102, 1103, };
            return { { 1, FormulaM.invoke("FETCH_BY_RAND", arr1, rand1), 30 }, };
        else
            arr1 = { 1104, 1105, };
            return { { 1, FormulaM.invoke("FETCH_BY_RAND", arr1, rand1), 15 }, };
        end
    end

    -- 废弃的货车
    if class == 785 then
        if rand > 40 then
            arr1 = { 1104, 1105, };
            return { { 1, FormulaM.invoke("FETCH_BY_RAND", arr1, rand1), 20 }, };
        else
            arr1 = { 1106, 1107, };
            return { { 1, FormulaM.invoke("FETCH_BY_RAND", arr1, rand1), 10 }, };
        end
    end

    -- 废弃的锅炉
    if class == 787 then
        if rand > 40 then
            arr = ItemM.getFoodMaterial(2);
            return { 1, FormulaM.invoke("FETCH_BY_RAND", arr, rand1), 20, };
        else
            arr = ItemM.getFoodMaterial(3);
            return { 1, FormulaM.invoke("FETCH_BY_RAND", arr, rand1), 10, };
        end
    end

    return {};
end
